package com.feixiang.control;

import java.util.Date;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.feixiang.bean.Blog;
import com.feixiang.service.BlogService;

@Controller
@RequestMapping(value="/blog")
public class BlogController {
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Resource
	private BlogService blogService;
	
	@RequestMapping(value="/addBlog",method=RequestMethod.POST)
	public String addBlog(@RequestParam(value="blogTitle",required=true)String blogTitle,
			@RequestParam(value="blogContext",required=true)String blogContext){
		Blog blog = new Blog();
		blog.setTextTitle(blogTitle);
		blog.setTextContent(blogContext);
		blog.setCategoryId(1l);
		blog.setCategoryName("test");
		blog.setCreatedTime(new Date());
		blog.setCreatStatus((short) 0);
		blog.setUserId(1l);
		blog.setUserName("love u");
		blogService.save(blog);
		logger.debug("保存成功");
	

		return "index";
	}

}
